﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title></title>
    <link href="../script/css/bootstrap.min.css" rel="stylesheet" />
    <script src="../script/js/jquery-1.12.3.js"></script>
    <script src="../script/js/bootstrap.min.js"></script>
    <script src="../script/js/common.js"></script>
</head>
<body>
    <style>
        .row {
            margin-top: 1em;
            margin-bottom: 0.5em;
            margin-left: 1em;
            margin-right: 1em;
        }
    </style>
    <div class="container-fluid">
        <div class="row" style="margin-top:4em;"></div>
        <div class="row">
            <div class="col-lg-4"></div>
            <div class="col-lg-4">
                <label>用户名：</label>
                <div><input class="form-control" /></div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-4"></div>
            <div class="col-lg-4">
                <label>密码：</label>
                <div><input class="form-control" type="password" /></div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-4"></div>
            <div class="col-lg-4">
                <div>
                    <button class="btn btn-default">登录</button>
                    <button class="btn btn-default">登出</button>
                </div>
                <a href="#">忘记密码？</a><a href="#" style="margin-left:2em;">注册新帐号？</a>
            </div>
        </div>
    </div>
    <script>
        var openid = '';
        $(function () {
            openid = getUrlParam("openid");
            if (openid == '') {
                $('div.container-fluid').remove();
                return;
            }
            $.get('/api/weixinLogin/autoLogin', { openid: openid }, function (data) {
                if (data.url != "") {
                    window.location.href = data.url;
                }

                $('button:eq(0)').click(function () {
                    $.get('/api/weixinLogin/login', {
                        username: $('input:eq(0)').val(),
                        pwd: $('input:eq(1)').val(),
                        openid: openid
                    }, function (data) {
                        window.location.href = data.url;
                    });
                });
                $('button:eq(1)').click(function () {
                    $.get('/api/login/loginOut', null, function (data) {
                        alert(data.msg);
                    });
                });
            });
        });
    </script>
</body>
</html>
